import React from "react";
import { AuthenticatedApp } from "authenticated-app";
import { UnauthenicatedApp } from "unauthenticated-app";
import "./App.css";

import { useAuth } from "./context/auth-context";
import { ErrorBoundary } from "components/error-boundary";
import { FullPageErrorFallback } from "./components/lib";
import { BrowserRouter as Router } from "react-router-dom";

function App() {
  const { user } = useAuth();
  return (
    <div className="App">
      <Router>
        <ErrorBoundary fallbackRender={FullPageErrorFallback}>
          {user ? <AuthenticatedApp /> : <UnauthenicatedApp />}
        </ErrorBoundary>
      </Router>
    </div>
  );
}

export default App;
